<?php

use yii\helpers\Url;
$this->inline("title","联系我们");
?>
<div class="panel">
    <div class="panel-body">
        <div class="row">
            <div class="col-sm-12">
                <div class="card-box">
                    <h4 class="m-t-0 m-b-30 header-title"><b>联系我们</b></h4>
                    <p class="text-muted font-13 m-b-30">
                        爱生活、爱分享、爱编程！
                    </p>
                    <form id="contact" onsubmit="return false">

                        <input type="hidden" name="<?php echo Yii::$app->request->csrfParam?>" value="<?php echo Yii::$app->request->csrfToken?>">
                        <input type="hidden" name="id" value="<?php echo empty($data['id']) ? '' : $data['id'];?>"/>
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <label>名称</label>
                                    <input class="form-control" value="<?php echo empty($data['name']) ? '' : $data['name']?>" name="name" placeholder="请输入单位或个人名称">
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <label>地址</label>
                                    <input class="form-control" value="<?php echo empty($data['address']) ? '' : $data['address']?>" name="address" placeholder="地址：北京/海淀" >
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <label>邮箱</label>
                                    <input class="form-control" value="<?php echo empty($data['mail']) ? '' : $data['mail']?>" name="mail" placeholder="科技，服务，金融等" >
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <label>QQ</label>
                                    <input class="form-control" value="<?php echo empty($data['qq']) ? '' : $data['qq']?>" name="qq" placeholder="QQ号码" >
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <label>微信</label>
                                    <input class="form-control" value="<?php echo empty($data['wechat']) ? '' : $data['wechat']?>" name="wechat" placeholder="微信号" >
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="form-group">
                                    <label>电话</label>
                                    <input class="form-control" value="<?php echo empty($data['tel']) ? '' : $data['tel']?>" name="tel" placeholder="电话" >
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label>描 述</label>
                            <textarea class="form-control" name="desc" placeholder="描述：这是一个神奇的网站"><?php echo empty($data['desc']) ? '' : $data['desc']?></textarea>
                        </div>

                        <div class="form-group text-right m-b-0">
                            <button class="btn btn-primary waves-effect waves-light" onclick="saveObj.save()" type="button">
                                提 交
                            </button>
                            <button type="reset" class="btn btn-default waves-effect waves-light m-l-5">
                                重 置
                            </button>
                            <button onclick="location.href='<?php echo Url::toRoute('/banner')?>'" type="button" class="btn btn-default waves-effect waves-light m-l-5">
                                返 回
                            </button>
                        </div>
                    </>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $this->beginBlock("jsText","append");?>
<script type="text/javascript">

    var saveObj = {
        ajaxLock:false,
        save:function () {
            that = this;
            var data = $("#contact").serialize();
            var submitUrl = "<?php echo Yii::$app->urlManager->createUrl(['contact/save'])?>";

            if (that.ajaxLock)return false;
            that.ajaxLock = true;

            $.ajax({
                data:data,
                url:submitUrl,
                type:'post',
                dataType:'json',
                success:function (resp) {
                    $.Notification.autoHideNotify(resp.state, 'bottom right', '提示信息',resp.message);
                    that.ajaxLock = false;
                },
                error:function () {
                    that.ajaxLock = false;
                }
            });
        }
    };
</script>
<?php $this->endBlock();?>
